package com.cn.xiaonuo.tcrfinance.tcrusers.controller;

import com.alibaba.fastjson.JSONObject;
import com.cn.xiaonuo.common.entity.BusinessMessage;
import com.cn.xiaonuo.common.utils.ApiJsonModel;
import com.cn.xiaonuo.tcrfinance.tcrusers.param.*;
import com.cn.xiaonuo.tcrfinance.tcrusers.service.LoginService;
import com.cn.xiaonuo.tcrfinance.tcrusers.service.PvLoginUserService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.*;

/**
 * 用户操作
 *
 * @author Mark sunlightcs@gmail.com
 */
@RestController
public class PvLoginUserController {

    @Autowired
    private LoginService loginServiceImpl;
    @Autowired
    private PvLoginUserService pvUserLoginService;
    /**
     * 资金信息查询
     */
    @ApiImplicitParams({
            @ApiImplicitParam(name = "accounts", value = "账户",example = "账户"),
            @ApiImplicitParam(name = "curTime", value = "时间",example = "时间")
    })
    @ApiOperation(value = "资金信息查询", notes = "资金信息查询")
    @PostMapping("/api/pvuser/capitalInfo")
    public BusinessMessage capitalInfo(@RequestBody Map<String,Object> params){
        return pvUserLoginService.capitalInfo(params);
    }

    /**
     * 当日买卖记录
     */
    @ApiOperation(value = "当日买卖记录", notes = "当日买卖记录")
    @ApiJsonModel({
            @ApiModelProperty(name = "accounts", value = "账户",example = "账户"),
            @ApiModelProperty(name = "phone", value = " 联系方式",example = "联系方式"),
            @ApiModelProperty(name = "curTime", value = " 时间",example = "时间"),
            @ApiModelProperty(name = "pageNo", value = "分页"),
            @ApiModelProperty(name = "pageSize", value = "分页大小",example = "分页大小"),
    })
    @PostMapping("/api/pvuser/queryBuySellByDate")
    public BusinessMessage queryBuySellByDate(@RequestBody Map<String,Object> params){
        return pvUserLoginService.queryBuySellByDate(params);
    }

    /**
     * 查询持有商品记录
     */
    @ApiImplicitParams({
            @ApiImplicitParam(name = "accounts", value = "账户",example = "账户"),
            @ApiImplicitParam(name = "phone", value = " 联系方式",example = "联系方式"),
            @ApiImplicitParam(name = "curTime", value = " 时间",example = "时间")
    })
    @ApiOperation(value = "查询持有商品记录", notes = "查询持有商品记录")
    @PostMapping("/api/pvuser/queryHoldProductList")
    public BusinessMessage queryHoldProductList(@RequestBody HoldProductListParam param){
        return pvUserLoginService.queryHoldProductList(param);
    }

    /**
     * 撤销线下打款操作
     */

    @ApiOperation(value = "和平村充值-撤销线下打款操作", notes = "和平村充值-撤销线下打款操作")
    @ApiJsonModel({
            @ApiModelProperty(name = "loginUserId", value = "操作员",example = "操作员"),
            @ApiModelProperty(name = "id", value = "主键",example = "主键")
    })
    @PostMapping("/api/pvuser/cancelPaymentOperation")
    public BusinessMessage cancelPaymentOperation(@RequestBody Map<String, Object> params) {
        BusinessMessage message = pvUserLoginService.cancelPaymentOperation(params);
        return message;
    }


    /**
     银行卡线下充值记录明细
     */
    @ApiOperation(value = "和平村充值-银行卡线下充值记录明细", notes = "和平村充值-银行卡线下充值记录明细")
    @PostMapping("/api/pvuser/offlineRechargeDetailed")
    public BusinessMessage offlineRechargeDetailed(@RequestBody PvUserReParam onlineUserReParam) {
        BusinessMessage message = pvUserLoginService.offlineRechargeDetailed(onlineUserReParam);
        return message;
    }

    /**
     * 验证银行卡收取的钱列表
     */
    @ApiOperation(value = "银行卡绑定扣款记录", notes = "银行卡绑定扣款记录")
    @PostMapping("/api/pvuser/queryUserYZBankCardInfo")
    public BusinessMessage queryUserYZBankCardInfo(@RequestBody PvUserReParam pvUserReParam) {
        BusinessMessage message = pvUserLoginService.queryUserYZBankCardInfo(pvUserReParam);
        return message;
    }
    /**
     * 管理后台用户取消提现
     */
    @ApiOperation(value = "取消提现", notes = "取消提现")
    @PostMapping("/api/pvuser/cancelTX")
    public BusinessMessage cancelTX(@RequestBody Map<String, Object> params) {
        BusinessMessage message = pvUserLoginService.cancelTX(params);
        return message;
    }

    /**
       查询所有用户信息和资金信息
     */
    @ApiOperation(value = "和平村充值-银行卡充值账户", notes = "和平村充值-银行卡充值账户")
    @PostMapping("/api/pvuser/selectUserInfoAndWallet")
    public BusinessMessage selectUserInfoAndWallet(@RequestBody PvUserReParam pvUserReParam) {
        BusinessMessage message = pvUserLoginService.selectUserInfoAndWallet(pvUserReParam);
        return message;
    }
    /**
     *
     */

    @ApiOperation(value = "和平村充值-线下充值", notes = "和平村购物卷收支记录-列表")
    @ApiJsonModel({
            @ApiModelProperty(name = "userId", value = "用户ID",example = "10086"),
            @ApiModelProperty(name = "loginUserId", value = "登录用户ID",example = "20086",required = true),
            @ApiModelProperty(name = "offlineRechargeAmount", value = "购货金额",example = "5700",required = true)
    })
    @PostMapping("/api/pvuser/offlineRecharge")
    public BusinessMessage offlineRecharge(@RequestBody Map<String, Object> params) {
        BusinessMessage message = pvUserLoginService.offlineRecharge(params);
        return message;
    }

    //验证码用户注册
    @ApiOperation(value = "验证码用户注册", notes = "验证码用户注册")
    @ApiJsonModel({
            @ApiModelProperty(name = "phone", value = "手机号",example = "手机号（true）",required = true),
            @ApiModelProperty(name = "pwdo", value = "新密码",example = "新密码（true）",required = true),
            @ApiModelProperty(name = "pwdt", value = "确认密码",example = "确认密码（true）",required = true),
//            @ApiModelProperty(name = "noteNum", value = "验证码",example = "验证码（true）",required = true)
    })
    @RequestMapping(value = "/api/common/login/userRegister", method = RequestMethod.POST)
    public BusinessMessage userRegister(@RequestBody JSONObject params) {
        BusinessMessage message = loginServiceImpl.userRegister(params);
        return message;
    }

    /**
     * 乡村振兴用户信息
     * @param pvUserParam
     * @return
     */
    @ApiOperation(value = "乡村振兴用户信息", notes = "乡村振兴用户信息")
    @PostMapping("/api/xczx/userInfo")
    public BusinessMessage userInfo(@RequestBody PvUserParam pvUserParam) {
        return pvUserLoginService.userInfo(pvUserParam);
    }

    /**
     * 用户启用/禁用
     * @param pvUserParam
     * @return
     */
    @ApiOperation(value = "用户启用/禁用", notes = "用户启用/禁用")
    @PostMapping("/api/xczx/updateUserStatus")
    public BusinessMessage updateUserStatus(@RequestBody PvUserParam pvUserParam) {
        return pvUserLoginService.updateUserStatus(pvUserParam);
    }

    @ApiOperation(value = "搜了宝充值", notes = "搜了宝充值")
    @PostMapping("/api/common/xczx/slbRecharge")
   public BusinessMessage slbRecharge(@RequestBody SlbRechargeParam param) {
        return pvUserLoginService.slbRecharge(param);
    }

    @ApiOperation(value = "财务系统用户列表", notes = "财务系统用户列表")
    @PostMapping("/api/sysUser/sysUserList")
    public BusinessMessage sysUserList() {
        return pvUserLoginService.sysUserList();
    }

    /**
     * 导出客户总报表
     *
     * @author lixiaolong
     * @date 2023-8-30 13:55:43
     */
    @ApiOperation(value = "持有商品_导出", notes = "持有商品_导出")
    @GetMapping("/api/queryHoldProductListExport")
    public void export(HttpServletResponse response, HoldProductListParam param) {
        pvUserLoginService.export(param);
    }


    @ApiOperation(value = "和平村充值-体验充值", notes = "和平村充值-体验充值")
    @PostMapping("/api/pvuser/experienceRecharge")
    public BusinessMessage experienceRecharge(@RequestBody ExperienceGoldParam params) {
        BusinessMessage message = pvUserLoginService.experienceRecharge(params);
        return message;
    }

    @ApiOperation(value = "会员信息-平台账户余额", notes = "会员信息-平台账户余额")
    @RequestMapping(value = "/api/pvUsers/accountBalance", method = RequestMethod.POST)
    public BusinessMessage accountBalance(@RequestBody AccountBalanceParam param) {
        BusinessMessage message = pvUserLoginService.accountBalance(param);
        return message;
    }

    @ApiOperation(value = "会员信息-商户账户余额", notes = "会员信息-商户账户余额")
    @RequestMapping(value = "/api/pvUsers/shopAccountBalance", method = RequestMethod.POST)
    public BusinessMessage shopAccountBalance(@RequestBody AccountBalanceParam param) {
        BusinessMessage message = pvUserLoginService.shopAccountBalance(param);
        return message;
    }

    @ApiOperation(value = "会员信息--寄售商品交易记录", notes = "会员信息--寄售商品交易记录")
    @PostMapping("/api/pvUser/consignmentTradeDetail")
    public BusinessMessage consignmentTradeDetail(@RequestBody ConsignmentParam consignmentParam) {
        BusinessMessage message = pvUserLoginService.consignmentTradeDetail(consignmentParam);
        return message;
    }
}
